package com.qf.day06.homework;

import java.util.Random;

//创建一个父类：Hero ，属性有 名字，力量，智力，敏捷， 方法有 徒手攻击（攻击力=力量的上下百分之20）

public class Hero {
    String name; // 名字
    double strength; // 力量
    double intelligence; //智力
    double agile; //敏捷

    //设置 set/get 用法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getStrength() {
        return strength;
    }

    public void setStrength(double strength) {
        this.strength = strength;
    }



    public double getIntelligence() {
        return intelligence;
    }

    public void setIntelligence(double intelligence) {
        this.intelligence = intelligence;
    }

    public double getAgile() {
        return agile;
    }

    public void setAgile(double agile) {
        this.agile = agile;
    }



//设置方法
    public void bareHandAttack(){
        double Strength =  getStrength();
        Random random = new Random();
        int num = random.nextInt(40)-20+1;//攻击力=力量的上下百分之20
       double strength = (num*0.01)*getStrength()+getStrength();
        System.out.println(this.name+"发动技能:徒手攻击,攻击力为"+strength);


    }
    //构造
    public Hero(String name, double strength, double intelligence, double agile) {
        this.name = name;
        this.strength = strength;
        this.intelligence = intelligence;
        this.agile = agile;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "姓名:" + name +
                ", 力量:" + strength +
                ", 智力:" + intelligence +
                ",敏捷:" + agile +
                '}';
    }
}
